<template>
  <div class="recommend">
    <div class="recommend-item" v-for="item in recommends.slice(1, 5)" :key="item.id">
      <a href="javascript:;" @click="goDetail(item.id)">
        <img v-lazy="item.cover_url" :alt="item.description" />
        <div>{{ item.title }}</div>
      </a>
    </div>
  </div>
</template>

<script>
import { useRouter } from "vue-router";

export default {
  props: {
    recommends: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  setup(props) {
    const router = useRouter();

    const goDetail = (id) => {
      router.push({ path: "/detail", query: { id } });
    };

    return {
      goDetail,
    };
  },
};
</script>

<style lang="scss" scoped>
.recommend {
  display: flex;
  width: 100%;
  text-align: center;
  padding: 15px 0 30px;
  border-bottom: 6px solid #eeeeee;
  font-size: 12px;
  .recommend-item {
    flex: 1;
    img {
      margin-bottom: 10px;
      width: 70px;
      height: 70px;
    }
  }
}
</style>
